package cn.topevery.garden.dal.logic;

import cn.topevery.garden.dal.dao.DeviceWarningDao;
import cn.topevery.garden.entity.po.DeviceWarning;
import cn.topevery.garden.entity.query.DeviceWarningQuery;
import cn.topevery.garden.entity.vo.DeviceWarningVO;
import cn.topevery.garden.framework.base.BaseLogic;
import hw.topevery.basis.dal.logic.SysClassExtLogic;
import hw.topevery.basis.dal.logic.SysUserLogic;
import hw.topevery.framework.db.base.BaseEntityDao;
import hw.topevery.framework.db.entity.DataPager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 设备报警记录表
 *
 * @author code-generate
 * @date 2021-09-06
 */
@Slf4j
@Service
public class DeviceWarningLogic extends BaseLogic<DeviceWarning> {
    @Autowired
    DeviceWarningDao deviceWarningDao;


    @Autowired
    private FacilitiesLogic facilitiesLogic;

    @Autowired
    private SysClassExtLogic sysClassExtLogic;

    @Autowired
    private SysUserLogic sysUserLogic;

    @Autowired
    private PersonLogic personLogic;


    @Override
    public BaseEntityDao<DeviceWarning, Integer> getDao() {
        return deviceWarningDao;
    }


    /**
     * 获取列表
     *
     * @param query
     */
    public DataPager<DeviceWarningVO> listPage(DeviceWarningQuery query) {
        return deviceWarningDao.listPage(query);
    }

    /**
     * 描述 公园一张图-运行监测-今日报警列表
     *
     * @return the today list data
     * @author wenzhao.lin
     * @created 2021 -09-14 17:55:06
     */
    public List<DeviceWarningVO> getTodayListData(){
        return deviceWarningDao.getTodayListData();
    }

    /**
     * 根据自增id批量删除
     *
     * @param ids
     */
    public void deleteBatchById(String userId, Integer[] ids) {
        deviceWarningDao.delete(userId, ids);
    }

    /**
     * 根据自增id保存或者更新
     *
     * @param deviceWarning 实体
     */
    public void saveOrUpdate(String userId, DeviceWarning deviceWarning) {
        deviceWarningDao.saveOrUpdate(userId, deviceWarning);
    }

    public void changeWarningStatus(String eventCode) {
        deviceWarningDao.changeWarningStatus(eventCode);
    }

    public List<Map<String, Object>> warningCount(Integer type) { return deviceWarningDao.warningCount(type); }
}
